package com.combetter.changxing.util;

import java.util.concurrent.TimeUnit;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;

/**
 * Created by 深圳唐龙飞讯科技有限公司 on 2018/6/19.
 */

public class RxUtil {
    public static Observable<Integer> countDown(final int time) {
        //延时0秒 轮询间隔1秒 轮询次数 time+1
        return Observable.interval(0, 1, TimeUnit.SECONDS).observeOn(AndroidSchedulers.mainThread(), false, 100)
                .map(aLong -> {
                    return time - aLong.intValue();
                }).take(time + 1);
    }
}
